<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    
    <title>My JSP 'roleedit.jsp' starting page</title>
    
    <link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>
  </head>
  
  <body>
    <form id="form" class="layui-form" action="#">
		<br>
		<div class="layui-form-item">
		<input type="hidden" name="roleId" value="${role.roleId }">
			<label class="layui-form-label">角色名</label>
			<div class="layui-input-block">
				<input type="text" name="roleName" value="${role.roleName }"style="width:200px" required
					lay-verify="required" placeholder="请输入角色名" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block">
				<input id="radio1" type="radio" name="roleState" value=0 title="关闭"> <input
					id="radio2" type="radio" name="roleState" value=1 title="正常" >
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">

				<button type="button" class="btn btn-primary" id="sub">确定</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>

  </body>
  <script type="text/javascript">
  $(document).ready(function() {
		if(${role.roleState}==1){
			$("#radio2").attr("checked","checked");
			
		}else{
			$("#radio1").attr("checked","checked");
		}
	});
  layui.use(['form','layer'], function() {
		var form = layui.form;
		var layer = layui.layer;
		$("#sub").click(function() {
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath}/role/editproc",
				data : $("#form").serialize(),
				dataType : "text",
				success : function(res) {
					if (res == "error") {
							var index = parent.layer.getFrameIndex(window.name);
							layer.alert('存在相同角色名', {
								skin : 'layui-layer-molv' //样式类名
								,
								closeBtn : 0
							}, function() {
								parent.layer.close(index);
							});
						
					} else if (res == "success") {
						
							var index = parent.layer.getFrameIndex(window.name);
							layer.alert('角色修改成功', {
								skin : 'layui-layer-molv' //样式类名
							,
								closeBtn : 0
							}, function() {
								parent.layer.close(index);
							});
					} else {
						alert("角色修改失败");
					}
				},
				error : function() {
					alert("error");
				}

			});
		});
	});
  
  </script>
</html>
